package com.yitiao.data_algorithms.leetcode.editor.cn;

class MergeStringsAlternately {
    // 2023-08-01 13:47:21
    public static void main(String[] args) {
        Solution solution = new MergeStringsAlternately().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public String mergeAlternately(String word1, String word2) {
            int max = Math.max(word1.length(), word2.length());
            int min = Math.max(word1.length(), word2.length());
            StringBuilder res = new StringBuilder();
            for (int i = 0; i < max; i++) {
                if (i < word1.length()) {
                    res.append(word1.charAt(i));
                }
                if (i < word2.length()) {
                    res.append(word2.charAt(i));
                }
            }
            return res.toString();
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}